import LoadManager from "../manager/LoadManager";

export default class HeroData{
    private _heroObj:object
    constructor(heroObj :object)
    {
        this._heroObj = heroObj
        this._h_id = heroObj["h_id"]
        this._id = heroObj["id"]
        this._atk = heroObj["atk"]
        this._def = heroObj["def"]
        this._hp = heroObj["hp"]
        this._mp = heroObj["mp"]
        this._lv = heroObj["lv"]
        this._exp = heroObj["exp"]
        this._starLv = heroObj["starLv"]
        this._allot_point = heroObj["allot_point"]
        this._quality = heroObj["quality"]
        let heroCfg = LoadManager.instance.getStaticConfigResByUrl("config/HeroConfig")
        this._temp = heroCfg[this._id]
    }
    private _temp:object
    private _h_id:number;
    //英雄唯一ID
    public get h_id() : number {
        return this._h_id;
    }
    private _id:number;
    //英雄ID
    public get id() : number {
        return this._id;
    }
    private _atk:number;
    public get atk() : number {
        return this._atk;
    }
    
    public get cur_atk() : number {
        return this._atk+(this._lv-1)*this._temp["grow_atk"]+50*(this._quality)
    }
    
    
    private _def:number;
    public get def() : number {
        return this._def;
    }
    public get cur_def() : number {
        return this._def+(this._lv-1)*this._temp["grow_def"]+50*(this._quality)
    }

    private _hp:number;
    public get hp() : number {
        return this._hp;
    }
    public get cur_hp() : number {
        return this._hp+(this._lv-1)*this._temp["grow_hp"]+50*(this._quality)
    }

    private _mp:number;
    public get mp() : number {
        return this._mp;
    }
    public get cur_mp() : number {
        return this._mp+(this._lv-1)*this._temp["grow_mp"]+50*(this._quality)
    }

    private _lv:number;
    public get lv() : number {
        return this._lv;
    }
    public set lv(v : number) {
        this._lv = v;
    }

    private _exp:number;
    public get exp() : number {
        return this._exp;
    }

    private _starLv:number;
    public get starLv() : number {
        return this._starLv;
    }
    
    private _allot_point:number;
    public get allot_point() : number {
        return this._allot_point;
    }

    private _quality:number;
    public get quality() : number {
        return this._quality;
    }
    
    public set quality(v : number) {
        this._quality = v;
    }
    

    public get qualityString() : string {
        let str = ""
        if(this._quality == 8){
            str = "宇宙级"
        }
        if(this._quality == 7){
            str = "神级"
        }
        if(this._quality == 6){
            str = "传说"
        }
        if(this._quality == 5){
            str = "史诗"
        }
        if(this._quality == 4){
            str = "稀有"
        }
        if(this._quality == 3){
            str = "高级"
        }
        if(this._quality == 2){
            str = "初级"
        }
        if(this._quality == 1){
            str = "不寻常"
        }
        if(this._quality == 0){
            str = "普通"
        }
        return str
    }
    
    private _nextQualityHeroData:HeroData
    public get nextQualityHeroData() : HeroData {
        if (!this._nextQualityHeroData)
        {
            this._nextQualityHeroData = new HeroData(this._heroObj)
            this._nextQualityHeroData.quality = this._quality + 1
        }
        
        return this._nextQualityHeroData
    }
    private _nextLvHeroData:HeroData
    public get nextLvHeroData() : HeroData {
        if (!this._nextLvHeroData)
        {
            this._nextLvHeroData = new HeroData(this._heroObj)
            this._nextLvHeroData.lv = this._lv + 1
        }
        return this._nextLvHeroData
    }
    
    public get avatarId() : string {
        return this._temp["avatarId"]
    }
    
    public get name() : string {
        return this._temp["name"]
    }
    
    
}